import nProgress from "nprogress";
import {ElMessageBox, ElNotification} from "element-plus";
import {SwitchButton} from "@element-plus/icons-vue";

// 加载全局Loading
export const showFullScreenLoading = () => nProgress.start();

// 隐藏全局Loading
export const hideFullScreenLoading = () => nProgress.done()

// 全局消息提示
export const toast = (
    message: string,
    type: "success" | "info" | "error" | "warning" = "success",
    dangerouslyUseHTMLString = true, // 解析返回的 html
    duration = 2500
) => {
    ElNotification({
        message,
        type,
        dangerouslyUseHTMLString,
        duration,
    });
};

// 弹出提交内容的输入框
export const showPrompt = (
    tip: string,
    value: string = ""
) => {
    return ElMessageBox.prompt("", tip, {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        inputValue: value,
    });
};

// confirm消息提示
export const showModal = (
    content = "",
    title = "",
    type: "success" | "info" | "error" | "warning" = "warning",
    icon: string | Component = "",
    draggable = false,
    overflow = false,
) => {
    return ElMessageBox.confirm(content, title, {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: type,
        icon: icon,
        customStyle: {
            // width: "50%",
            height: "auto",
        },
        draggable: draggable,
        overflow: overflow,
    });
};